<?php


/**
 * @author yaya
 * 群成员修改名片
 */
class MemberCardChanged {
	private $message = "";
	private $auth = null;
	private $cp = null;
	function MemberCardChanged() {
		$this->auth = new Authority();
		$this->cp = new ClusterParam();
	}

	public function run() {
		if($this->auth ->adminLevel >4) {
			$this->message = "才不告诉你们刚刚有人改名字了呢-。-";
			return;
		}
		
		if (isset ($_SESSION['changNum' . $_POST[ClusterNum]])) {
			$_SESSION['changNum' . $_POST[ClusterNum]] = $_SESSION['changNum' . $_POST[ClusterNum]] + 1;
		} else {
			$_SESSION['changNum' . $_POST[ClusterNum]] = 1;
		}

		$num = $this->cp->getParamValue('MEMBERCARDCHANGED_NUM');
		if ($_SESSION['changNum' . $_POST[ClusterNum]] > $num) {
			if ($_SESSION['changNum' . $_POST[ClusterNum]] > ($num +1))
				return;
			$this->message = $this->cp->getParamValue('MEMBERCARDCHANGED_ERROR_MESS');
			return;
		}

		$MEMBERCARDCHANGED_MESS = $this->cp->getParamValue('MEMBERCARDCHANGED_MESS');
		if (trim($_POST[Message]) == "索妮娅" || trim($_POST[Message]) == "索尼娅") {
			$this->message = $_POST[Nick] . "! 你个魂淡，不许冒充索妮娅酱";
			return;
		}
		$this->message = preg_replace(array (
			"/\{0\}/",
			"/\{1\}/"
		), array (
			$_POST[Nick],
			$_POST[Message]
		), $MEMBERCARDCHANGED_MESS);

	}

	private function __get($property_name) {
		return $this-> $property_name;
	}

	private function __set($property_name, $value) {
		$this->$property_name = $value;
	}
}
?>